package pingan.com.imandtwo.g_mvp;

import pingan.com.imandtwo.interfaces.ApiServers;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by 迷人的脚毛！！ on 2018/2/7.
 */

public class RetrofitUtil {
    private static volatile RetrofitUtil instant;
    private ApiServers apiService;


    private RetrofitUtil(String s) {
        Retrofit retrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .baseUrl(s)
                .build();

        apiService = retrofit.create(ApiServers.class);
    }

    public static RetrofitUtil getInstant(String s){
        if (null==instant){
            synchronized (RetrofitUtil.class){
                if (instant==null){
                    instant=new RetrofitUtil(s);
                }
            }
        }
        return instant;

    }
    public ApiServers getApiService(){
        return apiService;
    }
}
